class Stack:
    def __init__(self) :
        self.stack=[]

    def push(self,element):#进栈(从栈顶进)
        self.stack.append(element)

    def pop(self):#出栈(从栈顶出)
        return self.stack.pop()

    def get_top(self):# 取栈顶
        if self.stack:
            return self.stack[-1]
        else:
            return None
    def is_empty(self):
        return len(self.stack)==0
def bra_match(s):
    match={'}':'{',']':'[',')':'('}
    stack=Stack()
    for ch in s:
        if ch in{'(','[','{'}:
            stack.push(ch)
        else:#ch in {'{'},']',')'}
            if stack.is_empty():
                return False
            elif stack.get_top()==match[ch]:
                stack.pop()
            else:#stack.get_top()!=match[ch]
                return False
    if stack.is_empty:
        return True
    else:
        return False

if __name__=="__main__":
    print(bra_match('[{()}(){()}[]({}){}]'))
    print(bra_match('[(}]'))